﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>BootStrap Table使用</title>
    <link href="~/css/bootstrap-select.css" rel="stylesheet" />
    <link href="~/css/bootstrap-table.css" rel="stylesheet" />
    <link href="~/css/bootstrap.css" rel="stylesheet" />
    <link href="~/css/ui-dialog.css" rel="stylesheet" />
    <link href="/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="~/css/labelauty.css" rel="stylesheet" />
    <link href="~/css/lsj.css" rel="stylesheet" />
    <script src="~/js/jquery.min.js"></script>
    <script src="~/js/bootstrap.js"></script>
    <script src="~/js/bootstrap-select.js"></script>
    <script src="~/js/bootstrap-table.js"></script>
    <script src="~/js/bootstrap-table-zh-CN.js"></script>
    <script src="~/js/jquery.unobtrusive-ajax.js"></script>
    <script src="/js/content.min.js?v=1.0.0"></script>
    <script src="~/js/dialog-plus-min.js"></script>
    <script src="~/js/labelauty.js"></script>
    <script src="~/js/lsj/backups.js"></script>

    <script src="~/js/plugins/layer/laydate/laydate.js"></script>
</head>



<body>
    <div class="panel-body" style="padding-bottom:0px;">
        <div class="panel panel-default">
            <div class="panel-heading">查询条件</div>
            <div class="panel-body">
                <form id="formSearch" class="form-horizontal">
                    <div class="form-group" style="margin-top:15px">
                        <label class="control-label col-sm-1" for="txt_search_departmentname">备份名称</label>
                        <div class="col-sm-2">
                            <input type="text" class="form-control" id="fileName" name="fileName" required>
                        </div>
                        <label class="control-label col-sm-1" for="txt_search_statu">创建日期</label>
                        <div class="col-sm-4">
                            <input placeholder="开始日期" class="laydate-icon form-control layer-date" id="start_time" name="start_time" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
                            <input placeholder="结束日期" class="laydate-icon form-control layer-date" id="end_time" name="end_time" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
                        </div>
                        <div class="col-sm-4" style="text-align:left;">
                            <button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary">查询</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        @using Web.helper;
        @{
            var actionName = ViewContext.RouteData.Values["action"].ToString().ToLower();
            var manager_id = User.Identity.Name;
        }
        @Html.Raw(Html.select_auth(manager_id, actionName))
        <table id="tb_departments"></table>
    </div>

    @using (Ajax.BeginForm("", new { }, new AjaxOptions() { HttpMethod = "Post", OnSuccess = "tips(data)", OnBegin = "ValidateLog" }))
    {
        <div class="modal fade bs-example-modal-sm" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="z-index:1000">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">新增</h4>
                    </div>
                    <div class="modal-body">
                        <input type="hidden" name="id" class="form-control" id="id">
                        <div class="form-group">
                            <label for="txt_departmentname">数据库名</label>
                            <input type="text" name="txt_dbName" class="form-control" id="txt_dbName" placeholder="数据库名(必填)" value="@ViewData["dbName"]" required="" readonly="readonly">
                        </div>
                        <div class="form-group">
                            <label for="txt_parentdepartment">备份名称</label>
                            <input type="text" name="txt_fileName" class="form-control" id="txt_fileName" placeholder="备份名称(必填)" required="">
                        </div>
                        <div class="form-group">
                            <label for="txt_departmentname">备份类型</label>
                            @Html.Raw(Html.selet_backup())
                        </div>
                        <div class="form-group">
                            <label for="txt_parentdepartment">备份说明</label>
                            <input type="text" name="txt_remark" class="form-control" id="txt_remark" placeholder="备份说明">
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
                        <button class="btn btn-primary block full-width m-b" id="btn_submit" onclick="onck()"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
                    </div>
                </div>
            </div>
        </div>
    }
</body>
</html>




<script>

    //提交的onclick,此时还可以修改表单里面的值,且后台可以获取
    function onck() {
        $('.selectpicker').selectpicker('refresh');//不加这个,默认显示无法获取
    }

    //登录前js验证
    function ValidateLog() {

    }


    //登录回调函数
    function tips(data) {
        var d = dialog({
            padding: 30,
            content: data.msg
        });

        if (data.status == 0) {
            //添加成功

            //显示模态框
            d.show();
            //先关闭主窗体
            $('#myModal').modal('hide')
            //刷新数据
            $('#tb_departments').bootstrapTable('refresh', { url: '/Templet/GetBackupsList' });
            //关闭提示模态框
            setTimeout(function () {
                d.close().remove();
            }, 2000);
        } else if (data.pitchId != "") {
            point(data.pitchId, data.msg);
        } else {
            //添加失败
            d = dialog({
                padding:30,
                content: data.msg
            });
            //关闭提示模态框
            setTimeout(function () {
                d.close().remove();
            }, 2000);
        }
    }

    //输出提示信息
    function point(id,content)
    {
        var follow = document.getElementById(id);
        var d = dialog({
            align: 'bottom',
            content: '<span class="label label-warning">!</span> ' + content
        });
        d.show(follow);
        setTimeout(function () {
            d.close().remove();
        }, 2000);
    }

</script>